package cn.taobaoke.restful;


import cn.taobaoke.restful.datasource.TargetDataSource;
import cn.taobaoke.restful.domain.*;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ExportService {

    @TargetDataSource
    public List<AccountsEntity> getAccount(String domain, Long agentId) {
        return accountsRepository.findByAgentId(agentId);
    }

    @TargetDataSource
    public List<PIDEntity> getPID(String domain, Long agentId) {
        return pidRepository.findByAgentId(agentId);
    }

    @TargetDataSource
    public List<AccountsEntity> getAccounts(String domain) {
        return accountsRepository.findAll();
    }

    @TargetDataSource
    public List<AdminEntity> getAdmins(String domain) {
        return adminRepository.findAll();
    }

    @TargetDataSource
    public List<AgentEntity> getAgents(String domain) {
        return agentRepository.findAll();
    }

    @TargetDataSource
    public List<AgentGroupRelation> getAgentGroupRations(String domain) {
        return agentGroupRelationRepository.findAll();
    }

    @TargetDataSource
    public List<DocumentEntity> getDocuments(String domain) {
        return documentRepository.findAll();
    }

    @TargetDataSource
    public List<GlobalConfig> getGlobalConfigs(String domain) {
        return globalConfigRepository.findAll();
    }

    @TargetDataSource
    public List<NoticeEntity> getNotices(String domain) {
        return noticeRepository.findAll();
    }

    @TargetDataSource
    public List<OrderEntity> getOrders(String domain) {
        return orderRepository.findAll();
    }

    @TargetDataSource
    public List<PIDEntity> getPIDs(String domain) {
        return pidRepository.findAll();
    }

    @TargetDataSource
    public List<RobotEntity> getRobots(String domain) {
        return robotRepository.findAll();
    }

    @TargetDataSource
    public List<UserGroupRelation> getUserGroupRelations(String domain) {
        return userGroupRelationRepository.findAll();
    }

    @TargetDataSource
    public List<WxGroupEntity> getWxGroups(String domain) {
        return wxGroupRepository.findAll();
    }

    @TargetDataSource
    public List<UserEntity> getUsers(String domain) {
        return userRepository.findAll();
    }

    private final @NonNull AdminRepository adminRepository;
    private final @NonNull AccountsRepository accountsRepository;
    private final @NonNull AgentRepository agentRepository;

    private final @NonNull AgentGroupRelationRepository agentGroupRelationRepository;
    private final @NonNull DocumentRepository documentRepository;
    private final @NonNull GlobalConfigRepository globalConfigRepository;
    private final @NonNull NoticeRepository noticeRepository;
    private final @NonNull OrderRepository orderRepository;
    private final @NonNull PIDRepository pidRepository;
    private final @NonNull RobotRepository robotRepository;
    private final @NonNull UserRepository userRepository;
    private final @NonNull UserGroupRelationRepository userGroupRelationRepository;
    private final @NonNull WxGroupRepository wxGroupRepository;


}
